defmodule TimerLib do
    @moduledoc false

    import TimeLib
    import NaiveDateTime

    def start_next_timer(nil, _, _, _) do
        :skip
    end
    def start_next_timer([], _, _, _) do
        :skip
    end
    def start_next_timer(ts, mod, fun, args) when is_list(ts) do
        [[ts]] = ts
        ts != nil && start_next_timer(ts, mod, fun, args)
    end
    def start_next_timer(ts, mod, fun, args) do
        ts = string_to_date(ts)
        if  ts != nil do
            diff(ts, now(), :millisecond)
            |> abs()
            |> :timer.apply_after(mod, fun, args)
        end
    end


end
